package com.zyj.exam_app.user_manager.service.impl;

import com.zyj.exam_app.user_manager.bean.UserBean;
import com.zyj.exam_app.user_manager.mapper.UserMapper;
import com.zyj.exam_app.user_manager.service.UserManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserManagerServiceImpl implements UserManagerService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean addOneUser(UserBean userInfo) {
        //进行参数校验

        //校验账户是否存在

        //保存
        return 1 == userMapper.insertOneUser(userInfo);
    }

    @Override
    public List<UserBean> getAllUserInfo() {
        return userMapper.findAllUsers();
    }

    @Override
    public boolean deleteOneUser(String userId) {
        //参数校验

        //删除用户
        userMapper.deleteOneUser(userId);

        return true;
    }

    @Override
    public UserBean findUserById(String userId) {
        //校验userId

        //查询
        return userMapper.selectById(userId);
    }
}
